#include <test.h>

#include <stdlib.h>
#include <sys/time.h>

using namespace std;

namespace Y {
    long long GetTickCount() {
        struct timeval tv;
        gettimeofday(&tv, NULL);
        return tv.tv_sec * 1000 + tv.tv_usec / 1000;
        //return clock() * 1000 / CLOCKS_PER_SEC;
    }

    void ISortTest::GenerateRandomData(vector<int> &v) {
        for (vector<int>::iterator iter = v.begin(), end = v.end(); iter != end; ++iter) {
            *iter = rand();
        }
    }

    TTestResult ISortTest::Test(int inputSize) {
        vector<int> v(inputSize);
        GenerateRandomData(v);

        const long long start = GetTickCount();
        Sort(v);
        //usleep(1000 * 1000);
        const double end = GetTickCount();

        TTestResult res;
        res.Name = GetName();
        res.InputSize = inputSize;
        res.RunTime = end - start;

        return res;
    }
} // namespace Y
